package com.Rendering.UI.Controllers;


import com.NetWork.Netty.Client;
import com.NetWork.Netty.Server;
import com.core.Window.Main.Game;
import javafx.fxml.FXML;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;

public class GuiMainMenuController {
    @FXML
    public ImageView GameStart;


    @FXML
    public void mouseStartGame(MouseEvent mouseEvent) {
        Server.StartServer(8080);
        Client.startClient();
        Client.ConnectServer("localhost");


        Game.getInstance().setGameScene();



    }

    @FXML
    public void mouseEnteredGame(MouseEvent mouseEvent) {
    }

    @FXML
    public void mouseExitedGame(MouseEvent mouseEvent) {

    }

    @FXML
    public void MouseClickedJoinGame(MouseEvent event) {
        Game.ClientID = 2;
        Client.startClient();
        //Client.startClient("100.66.9.48");
        do {
            System.out.println("Waiting for Client connect to Server");
            Client.ConnectServer("100.66.9.48");
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        while (!Client.isConnected);

        Game.getInstance().setGameScene();
    }

}
